package net.fruit.mq.client;

import java.util.Properties;

import net.fruit.mq.client.order.OrderConsumer;
import net.fruit.mq.client.order.OrderProducer;
import net.fruit.mq.client.transaction.LocalTransactionChecker;
import net.fruit.mq.client.transaction.TransactionProducer;

/**
 * MQ客户端工厂类，用来创建客户端对象
 * 
 * @author CNJUN
 */
public class MQFactory {
    private static MQFactoryAPI mqFactory = null;

    static {
        mqFactory = new net.fruit.mq.client.impl.MQFactoryImpl();
    }
    
    /**
     * 创建Producer
     *
     * @param properties Producer的配置参数
     * @return
     */
    public static Producer createProducer(final Properties properties) {
        return mqFactory.createProducer(properties);
    }

    /**
     * 创建顺序Producer
     *
     * @param properties Producer的配置参数
     * @return
     */
    public static OrderProducer createOrderProducer(final Properties properties) {
        return mqFactory.createOrderProducer(properties);
    }

    /**
     * 创建事务Producer
     *
     * @param properties Producer的配置参数
     * @return
     */
    public static TransactionProducer createTransactionProducer(final Properties properties,
                                                                final LocalTransactionChecker checker) {
        return mqFactory.createTransactionProducer(properties, checker);
    }

    /**
     * 创建Consumer
     *
     * @param properties Consumer的配置参数
     * @return
     */
    public static Consumer createConsumer(final Properties properties) {
        return mqFactory.createConsumer(properties);
    }

    /**
     * 创建顺序Consumer
     *
     * @param properties Consumer的配置参数
     * @return
     */
    public static OrderConsumer createOrderedConsumer(final Properties properties) {
        return mqFactory.createOrderedConsumer(properties);
    }
}
